package misc;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;

/** functionalities that make living with java easier **/
public class utility {

	public static String typeOf(Object obj)
	{  
		String result = "could not be identified";
		Class cls = obj.getClass();  
		result = cls.getName();
		// System.out.println("The type of the object is: " + result);
		
		return result;
	}
	
	/** converts a array of strings, into a arraylist of strings **/
	public static ArrayList array_to_arraylist(String[] array)
	{  
		ArrayList<String> array_list = new ArrayList<String>(array.length);  
		for (String element : array) {
			array_list.add(element);
		}
		return array_list;
	}

	/** test if the object (array, string, hashmap, integer, float) is
	 * null
	 * or 
	 * does NOT contain ANY value/data (empty array, empty string "")
	 */
	public boolean empty(Object OBJECT)
	{
		boolean result = false;
		if(OBJECT == null)
		{
			result = true;
		}
		else if(typeOf(OBJECT) == "java.lang.String")
		{
			String object_string = (String) OBJECT; 
			if(object_string.equals("")) result = true;
		}
		else
		{
			System.out.println(typeOf(OBJECT));
		}
		
		return result;
	}

	/** test if the object (array, string, hashmap, integer, float) is !NOT
	 * null
	 * or 
	 * does NOT contain ANY value/data (empty array, empty string "")
	 */
	public boolean not_empty(Object OBJECT)
	{
		return !empty(OBJECT);
	}
}